package day04;
import java.util.Scanner;
//猜数字小游戏
public class Gussing {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = (int)(Math.random()*1000+1);
        System.out.println(num);
        /*
        System.out.println("猜吧！");
        int guss = scan.nextInt();
        while (guss!=num){
            if (guss>num){
                System.out.println("猜大了");
            }else {
                System.out.println("猜小了");
            }
            System.out.println("猜吧!");
            guss = scan.nextInt();
        }
        System.out.println("恭喜你，猜对了");
         */

        //假设800
        //300(小了) 1000(大了) 800(对)
        int guss;
        do {
            System.out.println("猜吧!");
            guss = scan.nextInt();
            if (guss>num){
                System.out.println("猜大了");
            }else if(guss<num){
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜你,猜对了");
            }
        }while (guss!=num);
    }
}
